Insertion Sort
code:hs
insertSort :: Ord a => a -> a insertSort = foldr insert' []
where
insert' :: Ord a => a -> a -> a insert' x (y:ys)
| x <= y = x : y : ys
| otherwise = y : insert' x ys
あるいは単に
code:hs
import Data.List (insert)
insertSort :: Ord a => a -> a insertSort = foldr insert []